Skip to content

Potential fix for code scanning alert no. 17: Incomplete URL substring sanitization - #9

Merged
KiidxAtlas merged 1 commit into
mainfrom
alert-autofix-17
Apr 1, 2026
Merged

KiidxAtlas merged 1 commit into
mainfrom
alert-autofix-17

Conversation

@KiidxAtlas

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/KiidxAtlas/python-hover/security/code-scanning/17

In general, to fix this kind of issue you must avoid substring checks on URLs or hostnames and instead perform exact or well-scoped comparisons against a whitelist of allowed hosts (or domains). For the Python docs, the canonical host is docs.python.org, and we should only treat URLs from that exact host (optionally with the www. prefix) as “Python docs”.

Concretely, in extension/src/ui/hoverPanel.ts, within getDocHostLabel, we already normalize the hostname by stripping a leading www.. The best minimal fix is to replace host.includes('docs.python.org') with a strict equality check: if the normalized host is exactly 'docs.python.org', return 'Python docs'; otherwise return host unchanged. This preserves existing behavior for legitimate Python docs URLs (whether they use https://docs.python.org/... or https://www.docs.python.org/...) while preventing other domains that merely contain that substring from being mis-labeled. No new methods or imports are required; we only change the conditional logic around that one line.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…g sanitization

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@KiidxAtlas
KiidxAtlas marked this pull request as ready for review April 1, 2026 04:44
@github-actions

github-actions Bot commented Apr 1, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 8dccac2.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@KiidxAtlas
KiidxAtlas merged commit 12013c6 into main Apr 1, 2026
4 of 7 checks passed
@KiidxAtlas
KiidxAtlas deleted the alert-autofix-17 branch April 1, 2026 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant